package avicit.bdp.dds.service.quartz;

import avicit.bdp.common.utils.SpringApplicationContext;
import org.quartz.utils.ConnectionProvider;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * druid connection provider
 */
public class DruidConnectionProvider implements ConnectionProvider {
	//因为系统用的是bonecp
    private final DataSource dataSource;

    public DruidConnectionProvider(){
        this.dataSource =  SpringApplicationContext.getBean(DataSource.class);
    }

    @Override
    public Connection getConnection() throws SQLException {
        return dataSource.getConnection();
    }

    @Override
    public void shutdown() throws SQLException {
        //dataSource.close();
    }

    @Override
    public void initialize() throws SQLException {
        //NOP
    }
}
